using UnityEngine;
using System.Collections.Generic;
namespace DesignPattern_Builder
{
    public class Product_1
    {
        //产品的组件
        private List<string> m_Part = new List<string>();
        public Product_1() { }
        public void AddPart(string Part) //添加产品的方法
        {
            m_Part.Add(Part);
        }
        public void ShowProduct()
        {
            Debug.Log("ShowProduct Functions:");
            foreach (string Part in m_Part)
                Debug.Log(Part);
        }
    }
    //介面用来生成Product的各零件 建造者基类
    public abstract class Builder_1
    {
        public abstract void BuildPart1(Product_1 theProduct);
        public abstract void BuildPart2(Product_1 theProduct);
    }
    // Builder介面的具体用作A
    public class ConcreteBuilderA_1 : Builder_1
    {
        public override void BuildPart1(Product_1 theProduct)
        {
            theProduct.AddPart("ConcreteBuilderA_Part11.0");
        }
        public override void BuildPart2(Product_1 theProduct)
        {
            theProduct.AddPart("ConcreteBuilderA_Part2bu");
        }
    }
    // Builder介面的具体用作B
    public class ConcreteBuilderB_1 : Builder_1
    {
        public override void BuildPart1(Product_1 theProduct)
        {
            theProduct.AddPart("ConcreteBuilderB_Part12.0");
        }
        public override void BuildPart2(Product_1 theProduct)
        {
            theProduct.AddPart("ConcreteBuilderB_Part2pi");
        }
    }
    //利用Builder介面來建構物件 指挥者 管理类
    public class Director_1
    {
        private Product_1 m_Product;

        public Director_1()
        {

        }
        public void Construct(Builder_1 theBuilder)
        {
            m_Product = new Product_1();
            theBuilder.BuildPart1(m_Product);
            theBuilder.BuildPart2(m_Product);
        }

        public Product_1 GetResult()
        {
            return m_Product;
        }
    }

   
}